package TestModel;

import java.util.*;

import model.*;
import junit.framework.*;
import org.junit.Test;

/*******************************************************************************
 * Course :					LOG210
 * Session :				winter 2012
 * Group :					02
 * Team :					3
 * Project :				Iteration 01
 * Students :				Nicolas Lefebvre			LEFN06078909
 * 							Jean-Philippe Chapdelaine	CHAJ13099001
							Dalin Son					SOND05099000
							Philippe Nichols			NICP29109007
 * Teacher :				François Caron
 * 							Jean-Philippe Martin
 * Created :				Feb 1, 2012
 * Date dern. modif. :		see revesion history
 * 
 * =============================================================
 *	Revision history
 * =============================================================
 *	Feb 1, 2012	Class created
 *******************************************************************************/
public class MenuTest extends TestCase
{
	private Menu m = new Menu();
	
	@Test
	public void testAdd()
	{
		this.m = new Menu();
		assertTrue(this.m.isEmpty());
		assertTrue(this.m.add(new Plat("Spag", "Pates avec une sauce � spaghetti � la viande et aux fines herbes")));
		this.m.add(new Plat("Steak", "Un gros steak"));
		assertFalse(this.m.add(null));
		assertEquals(2, this.m.size());
		Collection<Plat> p = new ArrayList<Plat>();
		p.add(new Plat("plat1", "plat1"));
		p.add(new Plat("plat2", "plat2"));
		p.add(new Plat("plat3", "plat3"));
		p.add(new Plat("plat4", "plat4"));
		assertTrue(this.m.addAll(p));
		assertEquals(6, this.m.size());
	}

	@Test
	public void testIterator()
	{
		this.m = new Menu();
		Collection<Plat> p = new ArrayList<Plat>();
		p.add(new Plat("plat1", "plat1"));
		p.add(new Plat("plat2", "plat2"));
		p.add(new Plat("plat3", "plat3"));
		p.add(new Plat("plat4", "plat4"));
		this.m.addAll(p);
		
		Iterator<Plat> i = this.m.iterator();
		
		assertEquals("plat1", i.next().getNom());
		assertEquals(new Plat("plat2", "plat2"), i.next());
		i.next(); //plat3
		assertTrue(i.hasNext());
		i.next(); //plat4
		assertFalse(i.hasNext());
	}
}
